home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 1 (Walnut Creek)
/
Aminet - June 1993 [Walnut Creek].iso
/
usenet
/
sources
/
volume89
/
editors
/
stevie36.6
< prev
next >
Wrap
Internet Message Format
|
1989-05-12
|
58KB
Path: xanth!indri!unmvax!ncar!ames!oliveb!sun!swap!page
From: page%swap@Sun.COM (Bob Page)
Newsgroups: comp.sources.amiga
Subject: v89i135: stevie - vi editor clone v3.6, Part06/06
Message-ID: <104422@sun.Eng.Sun.COM>
Date: 12 May 89 03:07:31 GMT
Sender: news@sun.Eng.Sun.COM
Lines: 1960
Approved: page@sun.com
Submitted-by: grwalter@watmath.waterloo.edu (Fred Walter)
Posting-number: Volume 89, Issue 135
Archive-name: editors/stevie36.6
# This is a shell archive.
# Remove anything above and including the cut line.
# Then run the rest of the file through 'sh'.
# Unpacked files will be owned by you and have default permissions.
#----cut here-----cut here-----cut here-----cut here----#
#!/bin/sh
# shar: SHell ARchive
# Run the following text through 'sh' to create:
# source.doc
# stevie.doc
# stevie.h
# tags
# term.h
# tos.c
# tos.h
# unix.c
# unix.h
# version.c
# This is archive 6 of a 6-part kit.
# This archive created: Thu May 11 19:41:29 1989
echo "extracting source.doc"
sed 's/^X//' << \SHAR_EOF > source.doc
X
X Release Notes for STEVIE - Version 3.10a
X
X Source Notes
X
X Tony Andrews - March 6, 1988
X
XOverview
X--------
X
X This file provides a brief description of the source code for
XStevie. The data structures are described later as well. For information
Xspecific to porting the editor, see the file 'porting.doc'. This document
Xis more relevant to people who want to hack on the editor apart from doing
Xa simple port.
X
X Most of this document was written some time ago so a lot of the
Xdiscussion centers on problems related to the Atari ST environment and
Xcompilers. Most of this can be ignored for other systems.
X
XThings You Need - ATARI
X-----------------------
X
X Stevie has been compiled with both the Alcyon (4.14A) and the
XMegamax C compilers. For the posted binary, Megamax was used because
Xit's less buggy and provides a reasonable malloc(). Ports to other
Xcompilers should be pretty simple. The current ifdef's for ALCYON and
XMEGAMAX should point to the potential trouble areas. (See 'porting.doc'
Xfor more information.)
X
X The search code depends on Henry Spencer's regular expression
Xcode. I used a version I got from the net recently (as part of a 'grep'
Xposting) and had absolutely no trouble compiling it on the ST. Thanks,
XHenry!
X
X The file 'getenv.c' contains a getenv routine that may or may
Xnot be needed with your compiler. My version works with Alcyon and
XMegamax, under either the Beckemeyer or Gulam shells.
X
X Lastly, you need a decent malloc. Lots of stuff in stevie is
Xallocated dynamically. The malloc with Alcyon is problematic because
Xit allocates from the heap between the end of data and the top of stack.
XIf you make the stack big enough to edit large files, you wind up
Xwasting space when working with small files. Mallocs that get their memory
Xfrom GEMDOS (in fairly large chunks) are much better.
X
XThings You Need - AMIGA
X-----------------------
X
X Lattice C version 5.0 or later.
X
XData Structures
X---------------
X
X A brief discussion of the evolution of the data structures will
Xdo much to clarify the code, and explain some of the strangeness you may
Xsee.
X
X In the original version, the file was maintained in memory as a
Xsimple contiguous buffer. References to positions in the file were simply
Xcharacter pointers. Due to the obvious performance problems inherent in
Xthis approach, the following changes were made.
X
X The file is now represented by a doubly linked list of 'line'
Xstructures defined as follows:
X
Xstruct line {
X struct line *next; /* next line */
X struct line *prev; /* previous line */
X char *s; /* text for this line */
X int size; /* actual size of space at 's' */
X unsigned long num; /* line "number" */
X};
X
XThe members of the line structure are described more completely here:
X
Xprev - pointer to the structure for the prior line, or NULL for the
X first line of the file
X
Xnext - like 'prev' but points to the next line
X
Xs - points to the contents of the line (null terminated)
X
Xsize - contains the size of the chunk of space pointed to by s. This
X is used so we know when we can add text to a line without getting
X more space. When we DO need more space, we always get a little
X extra so we don't make so many calls to malloc.
X
Xnum - This is a pseudo line number that makes it easy to compare
X positions within the file. Otherwise, we'd have to traverse
X all the links to tell which line came first.
X
X Since character pointers served to mark file positions in the
Xoriginal, a similar data object was needed for the new data structures.
XThis purpose is served by the 'lptr' structure which is defined as:
X
Xstruct lptr {
X struct line *linep; /* line we're referencing */
X int index; /* position within that line */
X};
X
XThe member 'linep' points to the 'line' structure for the line containing
Xthe location of interest. The integer 'index' is the offset into the line
Xdata (member 's') of the character to be referenced.
X
XThe following typedef's are more commonly used:
X
Xtypedef struct line LINE;
Xtypedef struct lptr LPtr;
X
XMany operations that were trivial with character pointers had to be
Ximplemented by functions or macros to manipulate LPtr's. Most of these are in
Xthe files 'ptrfunc.c' and 'macros.h'. There you'll find functions to increment,
Xdecrement, and compare LPtr's.
SHAR_EOF
echo "extracting stevie.doc"
sed 's/^X//' << \SHAR_EOF > stevie.doc
X
X STEVIE - Simply Try this Editor for VI Enthusiasts
X
X Quick Reference Card
X
X by
X
X Tony Andrews And G. R. (Fred) Walter
X
XSTEVIE may be freely distributed. The source isn't copyrighted or
Xrestricted in any way. If you pass the program along, please include all
Xthe documentation and, if practical, the source as well.
X
XSTEVIE used to stand for 'ST Editor for VI Enthusiasts', however since this
Xeditor is used on more machines than just ST's the acronym was changed.
X
XStarting the Editor
X-------------------
X
XThe following command line forms are supported:
X
X vi [file ...] Edit the specified file(s)
X
X vi -t tag Start at location of the given tag
X
X vi + file Edit file starting at end
X
X vi +n file Edit file starting a line number 'n'
X
X vi +/pat file Edit file starting at pattern 'pat'
X
XIf multiple files are given on the command line (using the first form),
Xthe ":n" command goes to the next file, ":p" goes backward in the list,
Xand ":rew" can be used to rewind back to the start of the file list.
X
XSet Command Options
X-------------------
X
XThe ":set" command works as usual to set parameters. Each parameter has
Xa long and an abbreviated name, either of which may be used. Boolean
Xparameters are set as in:
X
X set showmatch
X
Xor cleared by:
X
X set noshowmatch
X
XNumeric parameters are set as in:
X
X set scroll=5
X
XSeveral parameters may be set with a single command:
X
X set novb sm report=1
X
XTo see the status of all parameters use ":set all". Typing ":set" with
Xno arguments will show only those parameters that have been changed.
XThe supported parameters, their names, defaults, and descriptions are
Xshown below:
X
XFull Name Short Default Description
X------------------------------------------------------------------------------
Xvbell vb vb Use visual bell (novb for audible bell)
Xshowmatch sm nosm Showmatch mode
Xwrapscan ws ws Wrapscan (searches cross file start/end)
Xerrorbells eb noeb Ring bell when error messages are shown
Xshowmode mo nomo Show on status line when in insert mode
Xbackup bk nobk Leave backup in *.bak on file writes
Xreturn cr cr End lines with cr-lf when writing
Xlist list nolist Show tabs and newlines graphically
Xautoindent ai noai Start new line at same col as prior line
Xignorecase ic noic Ignore case in search strings
Xnumber nu nonu Display lines with their line numbers
X
Xscroll scroll 12 Number of lines to scroll for ^D and ^U
Xtabstop ts 8 Number of spaces in a tab
Xreport report 5 Min # of lines to report operations on
Xlines lines 25 Number of lines on the screen
X
XThe EXINIT environment variable can be used to modify the default values
Xon startup as in:
X
X setenv EXINIT="set sm ts=4"
X
XThe 'backup' parameter, if set, causes the editor to retain a backup of any
Xfiles that are written. During file writes, a backup is always kept for
Xsafety until the write is completed. At that point, the 'backup' parameter
Xdetermines whether the backup file is deleted.
X
XIn environments (e.g. OS/2 or TOS) where lines are normally terminated by
XCR-LF, the 'return' parameter allows files to be written with only a LF
Xterminator (if the parameter is cleared).
X
XThe 'lines' parameter tells the editor how many lines there are on the screen.
XThis is useful on systems like the ST where various screen resolutions may be
Xused. By using the 'lines' parameter, different screen sizes can be easily
Xhandled. On the Amiga system window resizes are atomatically detected and
Xacted upon. It is suggested that one's window be larger than 2 rows and 5
Xcolumns.
X
XColon Commands
X--------------
X
XSeveral of the normal 'vi' colon commands are supported by STEVIE. Some commands
Xmay be preceded by a line range specification. For commands that accept a range
Xof lines, the following address forms are supported:
X
Xaddr
Xaddr + number
Xaddr - number
X
Xwhere 'addr' may be one of the following:
X a line number
X a mark (as in 'a or 'b)
X % (entire file)
X . (the current line)
X $ (the last line)
X
XThe Global Command
X------------------
X
XA limited form of the global command is supported, accepting the following
Xcommand form:
X
Xg/pattern/X
X
Xwhere X may be either 'd' or 'p' to delete or print lines that match the given
Xpattern. If a line range is given, only those lines are checked for a match
Xwith the pattern. If no range is given, all lines are checked.
X
XIf the trailing command character is omitted, 'p' is assumed. In this case, the
Xtrailing slash is also optional. The current version of the editor does not
Xsupport the undo operation following the deletion of lines with the global
Xcommand.
X
XThe Substitute Command
X----------------------
X
XThe substitute command provides a powerful mechanism for making more complex
Xsubstitutions than can be done directly from visual mode. The general form of
Xthe command is:
X
Xs/pattern/replacement/g
X
XEach line in the given range (or the current line, if no range was given) is
Xscanned for the given regular expression. When found, the string that matched
Xthe pattern is replaced with the given replacement string. If the replacement
Xstring is null, each matching pattern string is deleted.
X
XThe trailing 'g' is optional and, if present, indicates that multiple
Xoccurrences of 'pattern' on a line should all be replaced.
X
XSome special sequences are recognized in the replacement string. The
Xampersand character is replaced by the entire pattern that was matched.
XFor example, the following command could be used to put all occurrences
Xof 'foo' or 'bar' within double quotes:
X
X1,$s/foo|bar/&/g
X
XThe special sequence "\n" where 'n' is a digit from 1 to 9, is replaced
Xby the string the matched the corresponding parenthesized expression in
Xthe pattern. The following command could be used to swap the first two
Xparameters in calls to the C function "foo":
X
X1,$s/foo\\(([^,]*),([^,]*),/foo(\\2,\\1,/g
X
XLike the global command, substitutions can't be undone with this version of
Xthe editor.
X
XThe Delete Command
X------------------
X
X:[range]d will delete the range of lines.
X
XFile Manipulation Commands
X--------------------------
X
X:w write the current file
X:wq write and quit
X:x write (if necessary) and quit
XZZ same as ":x"
X
X:e file edit the named file
X:e! re-edit the current file, discarding any changes
X:e # edit the alternate file
X
X:w file write the buffer to the named file
X:x,y w file write lines x through y to the named file
X:r file read the named file into the buffer
X
X:n edit the next file
X:p edit the previous file
X:rew rewind the file list
X
X:f show the current file name
X:f name change the current file name
X
X:ta tag go to the named tag
X^] like ":ta" using the current word as the tag
X
X:help display a command summary
X
XThe ":help" command can also be invoke with the <HELP> key on the Atari ST
Xor the Amiga. This actually displays a pretty complete summary of the real vi
Xwith unsupported features indicated appropriately.
X
XThe commands above work pretty much like they do in 'vi'. Most of the
Xcommands support a '!' suffix (if appropriate) to discard any pending
Xchanges.
X
XString Searches
X---------------
X
XString searches are supported, as in vi, accepting the usual regular
Xexpression syntax. This was done using Henry Spencer's regular expression
Xlibrary without modification. Tony Andrews added code outside the library to
Xsupport the '\<' and '\>' extensions and code inside the library to support
Xthe ignorecase option.
X
XOperators
X---------
X
XThe vi operators (d, c, y, <, and >) work as true operators.
X
XTags
X----
X
XTags are implemented.
X
XSystem-Specific Comments
X------------------------
X
XThe following sections provide additional relevant information for the
Xsystems to which STEVIE has been ported.
X
XAtari ST
X--------
X
XThe editor has been tested in all three resolutions, although low and
Xhigh res. are less tested than medium. The 50-line high res. mode can
Xbe used by setting the 'lines' parameter to 50. Alternatively, the
Xenvironment variable 'LINES' can be set. The editor doesn't actively
Xset the number of lines on the screen. It just operates using the number
Xof lines it was told.
X
XThe arrow keys, as well as the <INSERT>, <HELP>, and <UNDO> keys are
Xall mapped appropriately.
X
XUNIX
X----
X
XThe editor has been ported to UNIX System V release 3. It's hard-coded for
Xansi-style escape sequences and doesn't use the termcap/terminfo routines at
Xall.
X
XOS/2
X----
X
XMake sure 'ansi' mode is on (using the 'ansi' command).
XThe OS/2 console driver doesn't support insert/delete line, so STEVIE
Xbypasses the driver and makes the appropriate system calls directly.
XThis is all done in the system-specific part of the editor so the kludge
Xis at least localized.
X
XThe arrow keys, page up/down and home/end all do what you'd expect. The function
Xkeys are hard-coded to some useful macros until I can get true support for
Xmacros into the editor. The current mappings are:
X
XF1 :p <RETURN>
XF2 :n <RETURN>
XF3 :e # <RETURN>
XF4 :rew <RETURN>
XF5 [[
XF6 ]]
XF7 <<
XF8 >>
XF9 :x <RETURN>
XF10 :help <RETURN>
X
XS-F1 :p! <RETURN>
XS-F2 :n! <RETURN>
X
XMSDOS
X-----
X
XSTEVIE has been ported to MSDOS 3.3 on an AT using the Microsoft C compiler,
Xversion 5.10. The keyboard mappings are the same as for OS/2.
XThe only problem with the PC version is that the inefficiency of
Xthe screen update code becomes painfully apparent on slower machines.
X
XBSD 4.3
X-------
X
XThis port was done so it could be worked on in a main-frame enviroment.
X
XAmiga
X-----
X
XThe arrow keys and the help key are supported, as is window re-sizing.
XIt is strongly suggested that you not try to type in console commands
X(alt-esc in some keymaps, plus the appropriate other keys) since STEVIE
Xcaptures all console input. If you do type alt-esc then typing '|' will
Xreturn you to STEVIE.
X
XMissing Features
X----------------
X
X1. Macros with support for function keys.
X
X2. More "set" options.
X
X3. Many others...
X
XKnown Bugs and Problems
X-----------------------
X
X1. The yank buffer uses statically allocated memory, so yanks of more than
X 5K of text will fail. If a delete spans more than 5K, the program asks
X for confirmation before proceeding. That way, if you were moving text,
X you don't get screwed by the limited yank buffer. You just have to move
X smaller chunks at a time. All the internal buffers (yank, redo, etc.)
X need to be reworked to allocate memory dynamically.
X
X2. If you stay in insert mode for a long time (around 5K's worth of
X characters, including newlines) the insert buffer can overflow.
X When this happens you lose your ability to automatically undo the text just
X inserted and the redo/undo/(undo of undo) buffers are reset to the
X current position.
X
X3. Several other less bothersome glitches...
X
XCharacter Function Summary
X--------------------------
X
XThe following list describes the meaning of each character that's used
Xby the editor. In some cases characters have meaning in both command and
Xinsert mode; these are all described.
X
X^@ The null character. Not used in any mode. This character may not
X be present in the file, as is the case with vi.
X
X^B Backward one screen.
X
X^D Scroll the window down one half screen.
X
X^E Scroll the screen up one line.
X
X^F Forward one screen.
X
X^G Same as ":f" command. Displays file information.
X
X^H (BS) Moves cursor left one space in command mode. In insert mode, erases
X the last character typed.
X
X^J Move the cursor down one line.
X
X^L Clear and redraw the screen.
X
X^M (CR) Move to the first non-white character in the next line. In insert
X mode, a carriage return opens a new line for input.
X
X^N Move the cursor down a line.
X
X^P Move the cursor up a line.
X
X^U Scroll the window up one half screen.
X
X^V Indicates that the next character is should be treated as entered
X and not modified (used to enter control characters, etc.).
X
X^Y Scroll the screen down one line.
X
X^[ Escape cancels a pending command in command mode, and is used to
X terminate insert mode.
X
X^] Moves to the tag whose name is given by the word in which the cursor
X resides.
X
X^` Same as ":e #" if supported (system-dependent).
X
XSPACE Move the cursor right on column.
X
X$ Move to the end of the current line.
X
X% If the cursor rests on a paren '()', brace '{}', or bracket '[]',
X move to the matching one.
X
X' Used to move the cursor to a previously marked position, as in
X 'a or 'b. The cursor moves to the start of the marked line. The
X special mark '' refers to the "previous context".
X
X+ Same as carriage return, in command mode.
X
X, Reverse of the last t, T, f, or F command.
X
X- Move to the first non-white character in the previous line.
X
X. Repeat the last edit command.
X
X/ Start of a forward string search command. String searches may be
X optionally terminated with a closing slash. To search for a slash
X use '\/' in the search string.
X
X0 Move to the start of the current line. Also used within counts.
X
X1-9 Used to add 'count' prefixes to commands.
X
X: Prefix character for "ex" commands.
X
X; Repeat last t, T, f, or F command.
X
X< The 'left shift' operator.
X
X> The 'right shift' operator.
X
X? Same as '/', but search backward.
X
XA Append at the end of the current line.
X
XB Backward one blank-delimited word.
X
XC Change the rest of the current line.
X
XD Delete the rest of the current line.
X
XE End of the end of a blank-delimited word.
X
XF Find a character backward on the current line.
X
XG Go to the given line number (end of file, by default).
X
XH Move to the first non-white char. on the top screen line.
X
XI Insert before the first non-white char. on the current line.
X
XJ Join two lines.
X
XL Move to the first non-white char. on the bottom screen line.
X
XM Move to the first non-white char. on the middle screen line.
X
XN Reverse the last string search.
X
XO Open a new line above the current line, and start inserting.
X
XP Put the yank/delete buffer before the current cursor position.
X
XT Reverse search 'upto' the given character.
X
XW Move forward one blank-delimited word.
X
XX Delete one character before the cursor.
X
XY Yank the current line. Same as 'yy'.
X
XZZ Exit from the editor, saving changes if necessary.
X
X[[ Move backward one C function.
X
X]] Move forward one C function.
X
X^ Move to the first non-white on the current line.
X
X` Move to the given mark, as with '. The distinction between the two
X commands is important when used with operators. I support the
X difference correctly. If you don't know what I'm talking about,
X don't worry, it won't matter to you.
X
X~ Switch case of character under cursor.
X
Xa Append text after the cursor.
X
Xb Back one word.
X
Xc The change operator.
X
Xd The delete operator.
X
Xe Move to the end of a word.
X
Xf Find a character on the current line.
X
Xh Move left one column.
X
Xi Insert text before the cursor.
X
Xj Move down one line.
X
Xk Move up one line.
X
Xl Move right one column.
X
Xm Set a mark at the current position (e.g. ma or mb).
X
Xn Repeat the last string search.
X
Xo Open a new line and start inserting text.
X
Xp Put the yank/delete buffer after the cursor.
X
Xr Replace a character.
X
Xs Replace characters.
X
Xt Move forward 'upto' the given character on the current line.
X
Xu Undo the last edit.
X
Xw Move forward one word.
X
Xx Delete the character under the cursor.
X
Xy The yank operator.
X
Xz Redraw the screen with the current line at the top (zRETURN),
X the middle (z.), or the bottom (z-).
X
X| Move to the column given by the preceding count.
SHAR_EOF
echo "extracting stevie.h"
sed 's/^X//' << \SHAR_EOF > stevie.h
X/*
X * STEVIE - Simply Try this Editor for VI Enthusiasts
X *
X * Code Contributions By : Tim Thompson twitch!tjt
X * Tony Andrews onecom!wldrdg!tony
X * G. R. (Fred) Walter watmath!watcgl!grwalter
X */
X
X#include "env.h"
X
X#include <stdio.h>
X#ifndef ATARI
X# ifndef UNIX
X# include <stdlib.h>
X# endif
X#endif
X#include <ctype.h>
X#ifndef MWC
X# include <string.h>
X#endif
X#include "ascii.h"
X#include "keymap.h"
X#include "param.h"
X#include "term.h"
X#include "macros.h"
X
X#ifdef AMIGA
X/*
X * This is used to disable break signal handling.
X */
X#include <signal.h>
X#endif
X
Xextern char *strchr();
X
X#define NORMAL 0
X#define CMDLINE 1
X#define INSERT 2
X#define APPEND 3
X#define UNDO 4
X#define REDO 5
X#define PUT 6
X#define FORWARD 7
X#define BACKWARD 8
X#define VALID 9
X#define NOT_VALID 10
X#define VALID_TO_CURSCHAR 11
X#define UPDATE_CURSOR 12
X#define UPDATE_ALL 13
X
X/*
X * Boolean type definition and constants
X */
Xtypedef int bool_t;
X
X#ifndef TRUE
X# define FALSE (0)
X# define TRUE (1)
X#endif
X#define SORTOF (2)
X#define YES TRUE
X#define NO FALSE
X#define MAYBE SORTOF
X
X/*
X * Maximum screen dimensions
X */
X#define MAX_COLUMNS 140L
X
X/*
X * Buffer sizes
X */
X#define CMDBUFFSIZE MAX_COLUMNS /* size of the command processing buffer */
X
X#define LSIZE 512 /* max. size of a line in the tags file */
X
X#define IOSIZE (1024+1) /* file i/o and sprintf buffer size */
X
X#define YANKSIZE 5200 /* yank buffer size */
X#define INSERT_SIZE 5300 /* insert, redo and undo buffer size must be
X * bigger than YANKSIZE */
X#define REDO_UNDO_SIZE 5400 /* redo, undo and (undo an undo) buffer size
X * must be bigger than INSERT_SIZE */
X#define READSIZE 5500 /* read buffer size must be bigger than
X * YANKSIZE and REDO_UNDO_SIZE */
X
X/*
X * SLOP is the amount of extra space we get for text on a line during editing
X * operations that need more space. This keeps us from calling alloc every
X * time we get a character during insert mode. No extra space is allocated
X * when the file is initially read.
X */
X#define SLOP 10
X
X/*
X * LINEINC is the gap we leave between the artificial line numbers. This
X * helps to avoid renumbering all the lines every time a new line is
X * inserted.
X *
X * Since line numbers are stored in longs (32 bits), a LINEINC of 10000
X * lets us have > 200,000 lines and we won't have to renumber very often.
X */
X#define LINEINC 10000
X
X#define CHANGED Changed = TRUE
X#define UNCHANGED Changed = FALSE
X
X#define S_NOT_VALID NumLineSizes = -1
X
X#define S_LINE_NOT_VALID LineNotValid = TRUE
X
X#define S_CHECK_TOPCHAR_AND_BOTCHAR CheckTopcharAndBotchar = TRUE
X
X#define S_MUST_UPDATE_BOTCHAR MustUpdateBotchar = TRUE
X
X#define S_VALID_TO_CURSCHAR ValidToCurschar = TRUE
X
Xstruct line {
X struct line *next; /* next line */
X struct line *prev; /* previous line */
X char *s; /* text for this line */
X int size; /* actual size of space at 's' */
X unsigned long num; /* line "number" */
X};
X
X#define LINEOF(x) ((x)->linep->num)
X
Xstruct lptr {
X struct line *linep; /* line we're referencing */
X int index; /* position within that line */
X};
X
Xtypedef struct line LINE;
Xtypedef struct lptr LPtr;
X
Xstruct charinfo {
X char ch_size;
X char *ch_str;
X};
X
Xextern struct charinfo chars[];
X
Xextern int State;
Xextern int Rows;
Xextern int Columns;
Xextern int CheckTopcharAndBotchar;
Xextern int MustUpdateBotchar;
Xextern int ValidToCurschar;
Xextern int LineNotValid;
Xextern int NumLineSizes;
Xextern LINE **LinePointers;
Xextern char *LineSizes;
Xextern char *Filename;
Xextern LPtr *Filemem;
Xextern LPtr *Filetop;
Xextern LPtr *Fileend;
Xextern LPtr *Topchar;
Xextern LPtr *Botchar;
Xextern LPtr *Curschar;
Xextern LPtr *Insstart;
Xextern int Cursrow, Curscol, Cursvcol, Curswant;
Xextern bool_t set_want_col;
Xextern int Prenum;
Xextern bool_t Changed;
Xextern bool_t RedrawingDisabled;
Xextern bool_t UndoInProgress;
Xextern bool_t Binary;
Xextern char *IObuff;
Xextern char *Insbuffptr;
Xextern char *Insbuff;
Xextern char *Readbuffptr;
Xextern char *Readbuff;
Xextern char *Redobuffptr;
Xextern char *Redobuff;
Xextern char *Undobuffptr;
Xextern char *Undobuff;
Xextern char *UndoUndobuffptr;
Xextern char *UndoUndobuff;
Xextern char *Yankbuffptr;
Xextern char *Yankbuff;
Xextern char last_command;
Xextern char last_command_char;
X
Xextern char *strcpy();
X
X/* alloc.c */
Xchar *alloc();
Xchar *strsave();
Xvoid screenalloc();
Xvoid filealloc();
Xvoid freeall();
XLINE *newline();
Xbool_t canincrease();
X
X/* cmdline.c */
Xvoid readcmdline();
Xvoid dotag();
Xvoid msg();
Xvoid emsg();
Xvoid smsg();
Xvoid gotocmdline();
Xvoid wait_return();
X
X/* dec.c */
Xint dec();
X
X/* edit.c */
Xvoid edit();
Xvoid insertchar();
Xvoid getout();
Xvoid scrollup();
Xvoid scrolldown();
Xvoid beginline();
Xbool_t oneright();
Xbool_t oneleft();
Xbool_t oneup();
Xbool_t onedown();
X
X/* fileio.c */
Xvoid filemess();
Xvoid renum();
Xbool_t readfile();
Xbool_t writeit();
X
X/* s_io.c */
Xvoid s_clear();
Xvoid s_refresh();
Xvoid NotValidFromCurschar();
Xvoid Update_Botchar();
X
X/* help.c */
Xbool_t help();
X
X/* inc.c */
Xint inc();
X
X/* linefunc.c */
XLPtr *nextline();
XLPtr *prevline();
Xvoid coladvance();
X
X/* main.c */
Xvoid stuffReadbuff();
Xvoid stuffnumReadbuff();
Xchar vgetc();
Xchar vpeekc();
X
X/* mark.c */
Xvoid setpcmark();
Xvoid clrall();
Xvoid clrmark();
Xbool_t setmark();
XLPtr *getmark();
X
X/* misccmds.c */
Xbool_t OpenForward();
Xbool_t OpenBackward();
Xvoid fileinfo();
Xvoid inschar();
Xvoid insstr();
Xvoid delline();
Xbool_t delchar();
Xint cntllines();
Xint plines();
XLPtr *gotoline();
X
X/* normal.c */
Xvoid normal();
Xvoid ResetBuffers();
Xvoid AppendToInsbuff();
Xvoid AppendToRedobuff();
Xvoid AppendNumberToRedobuff();
Xvoid AppendToUndobuff();
Xvoid AppendNumberToUndobuff();
Xvoid AppendPositionToUndobuff();
Xvoid AppendToUndoUndobuff();
Xvoid AppendNumberToUndoUndobuff();
Xvoid AppendPositionToUndoUndobuff();
Xbool_t linewhite();
X
X/* mk.c */
Xchar *mkstr();
Xchar *mkline();
X
X/* param.c */
Xvoid doset();
X
X/* screen.c */
Xvoid cursupdate();
X
X/* search.c */
Xvoid doglob();
Xvoid dosub();
Xvoid searchagain();
Xbool_t dosearch();
Xbool_t repsearch();
Xbool_t searchc();
Xbool_t crepsearch();
Xbool_t findfunc();
XLPtr *showmatch();
XLPtr *fwd_word();
XLPtr *bck_word();
XLPtr *end_word();
X
X/* format_l.c */
Xchar *format_line();
X
X/*
X * Machine-dependent routines.
X */
X#ifdef AMIGA
X# include "amiga.h"
X#endif
X#ifdef BSD
X# include "bsd.h"
X#endif
X#ifdef UNIX
X# include "unix.h"
X#endif
X#ifdef TOS
X# include "tos.h"
X#endif
X#ifdef OS2
X# include "os2.h"
X#endif
X#ifdef DOS
X# include "dos.h"
X#endif
SHAR_EOF
echo "extracting tags"
sed 's/^X//' << \SHAR_EOF > tags
XISSPECIAL edit.c /^#define ISSPECIAL(c) ((c) == BS || (c) == NL ||/
Xalloc alloc.c /^alloc(size)$/
Xbadcmd cmdline.c /^badcmd()$/
Xbeginline edit.c /^beginline(flag)$/
Xcanincrease alloc.c /^canincrease(n)$/
Xdec dec.c /^dec(lp)$/
Xdoecmd cmdline.c /^doecmd(arg)$/
Xdoshell cmdline.c /^doshell()$/
Xdotag cmdline.c /^dotag(tag, force)$/
Xedit edit.c /^edit()$/
Xemsg cmdline.c /^emsg(s)$/
Xfilealloc alloc.c /^filealloc()$/
Xfreeall alloc.c /^freeall()$/
Xget_line cmdline.c /^get_line(cp)$/
Xget_range cmdline.c /^get_range(cp)$/
Xgetout edit.c /^getout(r)$/
Xgotocmdline cmdline.c /^gotocmdline(clr, firstc)$/
Xinsertchar edit.c /^insertchar(c)$/
Xmsg cmdline.c /^msg(s)$/
Xnewline alloc.c /^newline(nchars)$/
Xonedown edit.c /^onedown(n)$/
Xoneleft edit.c /^oneleft()$/
Xoneright edit.c /^oneright()$/
Xoneup edit.c /^oneup(n)$/
Xreadcmdline cmdline.c /^readcmdline(firstc, cmdline)$/
Xscreenalloc alloc.c /^screenalloc()$/
Xscrolldown edit.c /^scrolldown(nlines)$/
Xscrollup edit.c /^scrollup(nlines)$/
Xsmsg cmdline.c /^smsg(s, a1, a2, a3, a4, a5, a6, a7, a8, a9)$/
Xstrsave alloc.c /^strsave(string)$/
Xwait_return cmdline.c /^wait_return()$/
XMmain main.c /^main(argc, argv)$/
Xclrall mark.c /^clrall()$/
Xclrmark mark.c /^clrmark(line)$/
Xcoladvance linefunc.c /^coladvance(p, want_col)$/
Xfilemess fileio.c /^filemess(s)$/
Xgetmark mark.c /^getmark(c)$/
Xhelp help.c /^help()$/
Xinc inc.c /^inc(lp)$/
Xlongline help.c /^longline(p)$/
Xnextline linefunc.c /^nextline(curr)$/
Xprevline linefunc.c /^prevline(curr)$/
Xreadfile fileio.c /^readfile(fname, fromp, nochangename)$/
Xrenum fileio.c /^renum()$/
Xsetmark mark.c /^setmark(c)$/
Xsetpcmark mark.c /^setpcmark()$/
XstuffReadbuff main.c /^stuffReadbuff(s)$/
XstuffnumReadbuff main.c /^stuffnumReadbuff(n)$/
Xusage main.c /^usage()$/
Xvgetc main.c /^vgetc()$/
Xvpeekc main.c /^vpeekc()$/
Xwriteit fileio.c /^writeit(fname, start, end)$/
XAppendNumberToRedobuff normal.c /^AppendNumberToRedobuff(n)$/
XAppendNumberToUndoUndobuff normal.c /^AppendNumberToUndoUndobuff(n)$/
XAppendNumberToUndobuff normal.c /^AppendNumberToUndobuff(n)$/
XAppendPositionToUndoUndobuff normal.c /^AppendPositionToUndoUndobuff(column, row)$/
XAppendPositionToUndobuff normal.c /^AppendPositionToUndobuff(column, row)$/
XAppendToInsbuff normal.c /^AppendToInsbuff(s)$/
XAppendToRedobuff normal.c /^AppendToRedobuff(s)$/
XAppendToUndoUndobuff normal.c /^AppendToUndoUndobuff(s)$/
XAppendToUndobuff normal.c /^AppendToUndobuff(s)$/
XDEFAULT1 normal.c /^#define DEFAULT1(x) (((x) == 0) ? 1 : (x))$/
XIDCHAR normal.c /^#define IDCHAR(c) (isalpha(c) || isdigit(c) /
XOpenBackward misccmds.c /^OpenBackward(can_ai)$/
XOpenForward misccmds.c /^OpenForward(can_ai)$/
XResetBuffers normal.c /^ResetBuffers()$/
Xcntllines misccmds.c /^cntllines(pbegin, pend)$/
Xcursupdate screen.c /^cursupdate(type)$/
Xdelchar misccmds.c /^delchar(fixpos, undo)$/
Xdelline misccmds.c /^delline(nlines)$/
Xdochange normal.c /^dochange()$/
Xdodelete normal.c /^dodelete(redraw, setup_for_undo, try_to_yank)$/
Xdojoin normal.c /^dojoin(leading_space, strip_leading_spaces)$/
Xdoput normal.c /^doput(dir)$/
Xdoset param.c /^doset(arg, inter)$/
Xdoshift normal.c /^doshift(op)$/
Xdoyank normal.c /^doyank()$/
Xfileinfo misccmds.c /^fileinfo()$/
Xgotoline misccmds.c /^gotoline(n)$/
Xinschar misccmds.c /^inschar(c)$/
Xinsstr misccmds.c /^insstr(s)$/
Xlinewhite normal.c /^linewhite(p)$/
Xnormal normal.c /^normal(c)$/
Xplines misccmds.c /^plines(s)$/
Xshowparms param.c /^showparms(all)$/
Xstartinsert normal.c /^startinsert(startln)$/
Xtabinout normal.c /^tabinout(shift_type, num)$/
Xupdateline screen.c /^updateline()$/
XC0 search.c /^#define C0(c) (((c) == ' ') || ((c) == '\\t') || /
XC1 search.c /^#define C1(c) (isalpha(c) || isdigit(c) || ((c) /
XOTHERDIR search.c /^#define OTHERDIR(x) (((x) == FORWARD) ? BACKWA/
Xbck_word search.c /^bck_word(p, type)$/
Xbcksearch search.c /^bcksearch(str)$/
Xcls search.c /^cls(c)$/
Xcrepsearch search.c /^crepsearch(flag)$/
Xdoglob search.c /^doglob(lp, up, cmd)$/
Xdosearch search.c /^dosearch(dir, str)$/
Xdosub search.c /^dosub(lp, up, cmd)$/
Xend_word search.c /^end_word(p, type)$/
Xfindfunc search.c /^findfunc(dir)$/
Xformat_line format_l.c /^format_line(ptr, len)$/
Xfwd_word search.c /^fwd_word(p, type)$/
Xfwdsearch search.c /^fwdsearch(str)$/
Xmapstring search.c /^mapstring(s)$/
Xregerror search.c /^regerror(s)$/
Xrepsearch search.c /^repsearch(flag)$/
Xsearchagain search.c /^searchagain(dir)$/
Xsearchc search.c /^searchc(c, dir, type)$/
Xshowmatch search.c /^showmatch()$/
Xssearch search.c /^ssearch(dir, str)$/
XCTRL ascii.h /^#define CTRL(x) ((x) & 0x1f)$/
XNotValidFromCurschar s_io.c /^NotValidFromCurschar()$/
XUpdate_Botchar s_io.c /^Update_Botchar()$/
Xs_clear s_io.c /^s_clear()$/
Xs_refresh s_io.c /^s_refresh(type)$/
Xscreen_del s_io.c /^screen_del(row, nlines, total_rows)$/
Xscreen_ins s_io.c /^screen_ins(row, nlines, total_rows)$/
Xscreen_refresh s_io.c /^screen_refresh(type)$/
XLINE stevie.h 131
XLINEOF stevie.h /^#define LINEOF(x) ((x)->linep->num)$/
XLPtr stevie.h 132
XP param.h /^#define P(n) (params[n].value)$/
XRowNumber macros.h /^#define RowNumber(p) (UndoInProgress ? 0 : cntllin/
Xanyinput macros.h /^#define anyinput() (Readbuffptr != NULL)$/
Xbool_t stevie.h 54
Xbuf1line macros.h /^#define buf1line() (Filemem->linep->next == Fileen/
Xbufempty macros.h /^#define bufempty() (buf1line() && Filemem->linep->/
Xendofline macros.h /^#define endofline(p) \\$/
Xequal macros.h /^#define equal(a, b) (((a)->linep == (b)->linep) &&/
Xgchar macros.h /^#define gchar(lp) ((lp)->linep->s[(lp)->index])$/
Xgt macros.h /^#define gt(a, b) ((LINEOF(a) != LINEOF(b)) \\$/
Xgtoreq macros.h /^#define gtoreq(a, b) ((LINEOF(a) != LINEOF(b)) \\$/
Xlineempty macros.h /^#define lineempty(p) ((p)->linep->s[0] == NUL)$/
Xlt macros.h /^#define lt(a, b) ((LINEOF(a) != LINEOF(b)) \\$/
Xltoreq macros.h /^#define ltoreq(a, b) ((LINEOF(a) != LINEOF(b)) \\$/
Xmkline mk.c /^mkline(n)$/
Xmkstr mk.c /^mkstr(c)$/
Xpchar macros.h /^#define pchar(lp, c) ((lp)->linep->s[(lp)->index] /
Xpswap macros.h /^#define pswap(a, b) { LPtr pswaptmp; pswaptmp = a;/
Xstartofline macros.h /^#define startofline(p) ((p)->index == 0)$/
XGetCharacter amiga.c /^GetCharacter()$/
XSendPacket amiga.c /^SendPacket(pid, action, args, nargs)$/
Xbeep amiga.c /^beep()$/
Xcooked amiga.c /^cooked(afh)$/
Xdelay amiga.c /^delay()$/
Xflushbuf amiga.c /^flushbuf()$/
Xfopenb amiga.c /^fopenb(fname, mode)$/
XgetCSIsequence amiga.c /^getCSIsequence()$/
Xget_ConUnit amiga.c /^get_ConUnit(afh)$/
Xinchar amiga.c /^inchar()$/
Xoutchar amiga.c /^outchar(c)$/
Xoutstr amiga.c /^outstr(s)$/
Xraw amiga.c /^raw(afh)$/
Xsleep amiga.c /^sleep(n)$/
Xwindexit amiga.c /^windexit(r)$/
Xwindgoto amiga.c /^windgoto(r, c)$/
Xwindinit amiga.c /^windinit()$/
SHAR_EOF
echo "extracting term.h"
sed 's/^X//' << \SHAR_EOF > term.h
X/*
X * STEVIE - Simply Try this Editor for VI Enthusiasts
X *
X * Code Contributions By : Tim Thompson twitch!tjt
X * Tony Andrews onecom!wldrdg!tony
X * G. R. (Fred) Walter watmath!watcgl!grwalter
X */
X
X/*
X * This file contains the machine dependent escape sequences that the editor
X * needs to perform various operations. Some of the sequences here are
X * optional. Anything not available should be indicated by a null string.
X *
X * Insert/delete line sequences are necessary.
X */
X
X/*
X * The macro names here correspond (more or less) to the actual ANSI names
X */
X
X#ifdef ATARI
X#define T_ED "\033E" /* erase display (may optionally home cursor) */
X#define T_EL "\033l" /* erase the entire current line */
X#define T_IL "\033L" /* insert one line */
X#define T_DL "\033M" /* delete one line */
X#define T_CI "\033f" /* invisible cursor (very optional) */
X#define T_CV "\033e" /* visible cursor (very optional) */
X#define T_TP "" /* plain text */
X#define T_TI "" /* inverse-video text */
X#endif
X
X#ifdef UNIX
X/* The UNIX sequences are hard-wired for ansi-like terminals. */
X#define T_ED "\033[2J" /* erase display (may optionally home cursor) */
X#define T_END_D "\033[J" /* erase to end of display */
X#define T_EL "\033[2K" /* erase the entire current line */
X#define T_END_L "\033[K" /* erase to the end of the current line */
X#define T_IL "\033[L" /* insert one line */
X#define T_DL "\033[M" /* delete one line */
X#define T_CI "" /* invisible cursor (very optional) */
X#define T_CV "" /* visible cursor (very optional) */
X#define T_TP "" /* plain text */
X#define T_TI "" /* inverse-video text */
X#endif
X
X#ifdef BSD
X/* The BSD 4.3 sequences are hard-wired for ansi-like terminals. */
X#define T_ED "\033[2J" /* erase display (may optionally home cursor) */
X#define T_END_D "\033[J" /* erase to end of display */
X#define T_EL "\033[2K" /* erase the entire current line */
X#define T_END_L "\033[K" /* erase to the end of the current line */
X#define T_IL "\033[L" /* insert line */
X#define T_DL "\033[M" /* delete line */
X#define T_CI "" /* invisible cursor */
X#define T_CV "" /* visible cursor */
X#define T_TP "\033[m" /* plain text */
X#define T_TI "\033[7m" /* inverse-video text */
X#endif
X
X#ifdef OS2
X/*
X * The OS/2 ansi console driver is pretty deficient. No insert or delete line
X * sequences. The erase line sequence only erases from the cursor to the end
X * of the line. For our purposes that works out okay, since the only time
X * T_EL is used is when the cursor is in column 0.
X *
X * The insert/delete line sequences marked here are actually implemented in
X * the file os2.c using direct OS/2 system calls. This makes the capability
X * available for the rest of the editor via appropriate escape sequences
X * passed to outstr().
X */
X#define T_ED "\033[2J" /* erase display (may optionally home cursor) */
X#define T_EL "\033[K" /* erase the entire current line */
X#define T_END_L "\033[K" /* erase to the end of the current line */
X#define T_IL "\033[L" /* insert one line - fake (see os2.c) */
X#define T_DL "\033[M" /* delete one line - fake (see os2.c) */
X#define T_CI "" /* invisible cursor (very optional) */
X#define T_CV "" /* visible cursor (very optional) */
X#define T_TP "" /* plain text */
X#define T_TI "" /* inverse-video text */
X#endif
X
X#ifdef AMIGA
X/*
X * The erase line sequence only erases from the cursor to the end of the
X * line. For our purposes that works out okay, since the only time T_EL is
X * used is when the cursor is in column 0.
X */
X#define T_ED "\014" /* erase display (may optionally home cursor) */
X#define T_END_D "\033[J" /* erase to end of display */
X#define T_EL "\033[K" /* erase the entire current line */
X#define T_END_L "\033[K" /* erase to the end of the current line */
X#define T_IL "\033[" /* insert line */
X#define T_IL_B "L"
X#define T_DL "\033[" /* delete line */
X#define T_DL_B "M"
X#define T_CI "\033[0 p" /* invisible cursor (very optional) */
X#define T_CV "\033[1 p" /* visible cursor (very optional) */
X#define T_TP "\033[0m" /* plain text */
X#define T_TI "\033[7m" /* inverse-video text */
X#endif
X
X#ifdef DOS
X/*
X * DOS sequences
X *
X * Some of the following sequences require the use of the "nansi.sys"
X * console driver. The standard "ansi.sys" driver doesn't support
X * sequences for insert/delete line.
X */
X#define T_ED "\033[2J" /* erase display (may optionally home cursor) */
X#define T_EL "\033[K" /* erase the entire current line */
X#define T_IL "\033[L" /* insert line (requires nansi.sys driver) */
X#define T_DL "\033[M" /* delete line (requires nansi.sys driver) */
X#define T_CI "" /* invisible cursor (very optional) */
X#define T_CV "" /* visible cursor (very optional) */
X#define T_TP "" /* plain text */
X#define T_TI "" /* inverse-video text */
X#endif
SHAR_EOF
echo "extracting tos.c"
sed 's/^X//' << \SHAR_EOF > tos.c
X/*
X * System-dependent routines for the Atari ST.
X */
X
X#include "stevie.h"
X
X#include <osbind.h>
X
X/*
X * The following buffer is used to work around a bug in TOS. It appears that
X * unread console input can cause a crash, but only if console output is
X * going on. The solution is to always grab any unread input before putting
X * out a character. The following buffer holds any characters read in this
X * fashion. The problem can be easily produced because STEVIE can't yet keep
X * up with the normal auto-repeat rate in insert mode.
X */
X#define IBUFSZ 128
X
Xstatic long inbuf[IBUFSZ]; /* buffer for unread input */
Xstatic long *inptr = inbuf; /* where to put next character */
X
X/*
X * inchar() - get a character from the keyboard
X *
X * Certain special keys are mapped to values above 0x80. These mappings are
X * defined in keymap.h. If the key has a non-zero ascii value, it is simply
X * returned. Otherwise it may be a special key we want to map.
X *
X * The ST has a bug involving keyboard input that seems to occur when typing
X * quickly, especially typing capital letters. Sometimes a value of
X * 0x02540000 is read. This doesn't correspond to anything on the keyboard,
X * according to my documentation. My solution is to loop when any unknown key
X * is seen. Normally, the bell is rung to indicate the error. If the "bug"
X * value is seen, we ignore it completely.
X */
Xint
Xinchar()
X{
X for (;;) {
X long c, *p;
X
X /*
X * Get the next input character, either from the input buffer or
X * directly from TOS.
X */
X if (inptr != inbuf) { /* input in the buffer, use it */
X c = inbuf[0];
X /*
X * Shift everything else in the buffer down. This would be
X * cleaner if we used a circular buffer, but it really isn't
X * worth it.
X */
X inptr--;
X for (p = inbuf; p < inptr; p++)
X *p = *(p + 1);
X } else
X c = Crawcin();
X
X if ((c & 0xff) != 0)
X return ((int) c);
X
X switch ((int) (c >> 16) & 0xff) {
X
X case 0x62:
X return K_HELP;
X case 0x61:
X return K_UNDO;
X case 0x52:
X return K_INSERT;
X case 0x47:
X return K_HOME;
X case 0x48:
X return K_UARROW;
X case 0x50:
X return K_DARROW;
X case 0x4b:
X return K_LARROW;
X case 0x4d:
X return K_RARROW;
X case 0x29:
X return K_CGRAVE; /* control grave accent */
X /*
X * Occurs due to a bug in TOS.
X */
X case 0x54:
X break;
X /*
X * Add the function keys here later if we put in support for
X * macros.
X */
X default:
X beep();
X break;
X }
X }
X}
X/*
X * get_inchars - snarf away any pending console input
X *
X * If the buffer overflows, we discard what's left and ring the bell.
X */
Xstatic void
Xget_inchars()
X{
X while (Cconis()) {
X if (inptr >= &inbuf[IBUFSZ]) { /* no room in buffer? */
X Crawcin(); /* discard the input */
X beep(); /* and sound the alarm */
X } else
X *inptr++ = Crawcin();
X }
X}
X
Xvoid
Xoutchar(c)
X char c;
X{
X get_inchars();
X Cconout(c);
X}
X
Xvoid
Xoutstr(s)
X char *s;
X{
X get_inchars();
X Cconws(s);
X}
X
X#define BGND 0
X#define TEXT 3
X
X/*
X * vbeep() - visual bell
X */
Xstatic void
Xvbeep()
X{
X int text, bgnd; /* text and background colors */
X long l;
X
X text = Setcolor(TEXT, -1);
X bgnd = Setcolor(BGND, -1);
X
X Setcolor(TEXT, bgnd); /* swap colors */
X Setcolor(BGND, text);
X
X for (l = 0; l < 5000; l++); /* short pause */
X
X Setcolor(TEXT, text); /* restore colors */
X Setcolor(BGND, bgnd);
X}
X
Xvoid
Xbeep()
X{
X if (RedrawingDisabled)
X return;
X
X if (P(P_VB))
X vbeep();
X else
X outchar('\007');
X}
X
X/*
X * remove(file) - remove a file
X */
Xvoid
Xremove(file)
X char *file;
X{
X Fdelete(file);
X}
X
X/*
X * rename(of, nf) - rename existing file 'of' to 'nf'
X */
Xvoid
Xrename(of, nf)
X char *of, *nf;
X{
X Fdelete(nf); /* if 'nf' exists, remove it */
X Frename(0, of, nf);
X}
X
Xvoid
Xwindinit()
X{
X if (Getrez() == 0)
X Columns = 40; /* low resolution */
X else
X Columns = 80; /* medium or high */
X
X P(P_LI) = Rows = 25;
X
X Cursconf(1, NULL);
X}
X
Xvoid
Xwindexit(r)
X int r;
X{
X exit(r);
X}
X
Xvoid
Xwindgoto(r, c)
X int r, c;
X{
X outstr("\033Y");
X outchar(r + 040);
X outchar(c + 040);
X}
X
X#ifndef MWC
X/*
X * System calls or library routines missing in TOS.
X */
X
Xvoid
Xsleep(n)
X int n;
X{
X int k;
X
X k = Tgettime();
X while (Tgettime() <= k + n);
X}
X#endif
X
Xvoid
Xdelay()
X{
X long n;
X
X for (n = 0; n < 8000; n++);
X}
X
X#ifndef MWC
Xint
Xsystem(cmd)
X char *cmd;
X{
X char arg[1];
X
X arg[0] = (char) 0; /* no arguments passed to the shell */
X
X if (Pexec(0, cmd, arg, 0L) < 0)
X return -1;
X else
X return 0;
X}
X#endif
X
X#ifdef MEGAMAX
Xchar *
Xstrchr(s, c)
X char *s;
X int c;
X{
X do {
X if (*s == c)
X return (s);
X } while (*s++);
X return (NULL);
X}
X#endif
X
X#ifdef FOPENB
X
XFILE *
Xfopenb(fname, mode)
X char *fname;
X char *mode;
X{
X char modestr[10];
X
X sprintf(modestr, "b%s", mode);
X
X return fopen(fname, modestr);
X}
X
X#endif
X
X#ifndef MWC
X/*
X * getenv() - get a string from the environment
X *
X * Both Alcyon and Megamax are missing getenv(). This routine works for both
X * compilers and with the Beckemeyer and Gulam shells. With gulam, the
X * env_style variable should be set to either "mw" or "gu".
X */
Xchar *
Xgetenv(name)
X char *name;
X{
X extern long _base;
X char *envp, *p;
X
X envp = *((char **) (_base + 0x2c));
X
X for (; *envp; envp += strlen(envp) + 1) {
X if (strncmp(envp, name, strlen(name)) == 0) {
X p = envp + strlen(name);
X if (*p++ == '=')
X return p;
X }
X }
X return (char *) 0;
X}
X#endif
SHAR_EOF
echo "extracting tos.h"
sed 's/^X//' << \SHAR_EOF > tos.h
X/*
X * Atari Machine-dependent routines.
X */
X
Xint inchar();
Xvoid outchar();
Xvoid outstr(), beep();
Xvoid remove(), rename();
Xvoid windinit(), windexit(), windgoto();
Xvoid delay();
Xvoid sleep();
SHAR_EOF
echo "extracting unix.c"
sed 's/^X//' << \SHAR_EOF > unix.c
X/*
X * System-dependent routines for UNIX System V Release 3.
X */
X
X#include "stevie.h"
X/* #include <termio.h> /* System V */
X#include <curses.h> /* BSD */
X
X/*
X * inchar() - get a character from the keyboard
X */
Xint
Xinchar()
X{
X char c;
X
X flushbuf(); /* flush any pending output */
X
X while (read(0, &c, 1) != 1);
X
X return (int) c;
X}
X
X#define BSIZE 2048
Xstatic char outbuf[BSIZE];
Xstatic int bpos = 0;
X
Xflushbuf()
X{
X if (bpos != 0)
X write(1, outbuf, bpos);
X bpos = 0;
X}
X
X/*
X * Macro to output a character. Used within this file for speed.
X */
X#define outone(c) outbuf[bpos++] = c; if (bpos >= BSIZE) flushbuf()
X
X/*
X * Function version for use outside this file.
X */
Xvoid
Xoutchar(c)
X char c;
X{
X outbuf[bpos++] = c;
X if (bpos >= BSIZE)
X flushbuf();
X}
X
Xvoid
Xoutstr(s)
X char *s;
X{
X while (*s) {
X outone(*s++);
X }
X}
X
Xvoid
Xbeep()
X{
X if (RedrawingDisabled)
X return;
X
X outone('\007');
X}
X
X/*
X * remove(file) - remove a file
X */
Xvoid
Xremove(file)
X char *file;
X{
X unlink(file);
X}
X
X/*
X * rename(of, nf) - rename existing file 'of' to 'nf'
X */
Xvoid
Xrename(of, nf)
X char *of, *nf;
X{
X unlink(nf);
X link(of, nf);
X unlink(of);
X}
X
Xvoid
Xdelay()
X{
X /* not implemented */
X}
X
Xstatic struct termio ostate;
X
Xvoid
Xwindinit()
X{
X char *getenv();
X char *term;
X struct termio nstate;
X
X if ((term = getenv("TERM")) == NULL || strcmp(term, "vt100") != 0) {
X fprintf(stderr, "Invalid terminal type '%s'\n", term);
X exit(1);
X }
X Columns = 80;
X P(P_LI) = Rows = 24;
X
X /*
X * Go into cbreak mode
X */
X ioctl(0, TCGETA, &ostate);
X nstate = ostate;
X nstate.c_lflag &= ~(ICANON | ECHO | ECHOE | ECHOK | ECHONL);
X nstate.c_cc[VMIN] = 1;
X nstate.c_cc[VTIME] = 0;
X ioctl(0, TCSETAW, &nstate);
X}
X
Xvoid
Xwindexit(r)
X int r;
X{
X /*
X * Restore terminal modes
X */
X ioctl(0, TCSETAW, &ostate);
X
X exit(r);
X}
X
X#define outone(c) outbuf[bpos++] = c; if (bpos >= BSIZE) flushbuf()
X
Xvoid
Xwindgoto(r, c)
X int r, c;
X{
X r += 1;
X c += 1;
X
X /*
X * Check for overflow once, to save time.
X */
X if (bpos + 8 >= BSIZE)
X flushbuf();
X
X outbuf[bpos++] = '\033';
X outbuf[bpos++] = '[';
X if (r >= 10)
X outbuf[bpos++] = r / 10 + '0';
X outbuf[bpos++] = r % 10 + '0';
X outbuf[bpos++] = ';';
X if (c >= 10)
X outbuf[bpos++] = c / 10 + '0';
X outbuf[bpos++] = c % 10 + '0';
X outbuf[bpos++] = 'H';
X}
X
XFILE *
Xfopenb(fname, mode)
X char *fname;
X char *mode;
X{
X return fopen(fname, mode);
X}
SHAR_EOF
echo "extracting unix.h"
sed 's/^X//' << \SHAR_EOF > unix.h
X/*
X * Unix Machine-dependent routines.
X */
X
Xint inchar();
Xvoid outchar();
Xvoid outstr(), beep();
Xvoid remove(), rename();
Xvoid windinit(), windexit(), windgoto();
Xvoid delay();
SHAR_EOF
echo "extracting version.c"
sed 's/^X//' << \SHAR_EOF > version.c
X/*
X * STEVIE - Simply Try this Editor for VI Enthusiasts
X *
X * Code Contributions By : Tim Thompson twitch!tjt
X * Tony Andrews onecom!wldrdg!tony
X * G. R. (Fred) Walter watmath!watcgl!grwalter
X */
X
X/*
X * Version Changes (and person who did them)
X * ------- ---------------------------------
X * 3.10 - version that started it all. Found on comp.sources.unix
X * Jun88 Volume 15 i037, i038, i039, i040, i042, and INF3
X * - Tim Thompson and Tony Andrews
X *
X * 3.10A - took version of STEVIE posted to usenet and added Amiga
X * and BSD support; added undo and redo commands; sped up
X * output to screen; sped up on-screen activities (such as
X * cursoring); fixed miscellaneous small bugs and changed some
X * commands so that they more closely resembled vi.
X * - GRWalter (Fred)
X *
X * 3.11B - added the ability to be run in the background (STEVIE will
X * attempt to use the current window, but if it can't then it
X * will open its own window). Fixed some other miscellaneous
X * bugs (some to do with re-sizing the screen, one to do with
X * undo'ing changes on lines that start with whitespace).
X * - GRWalter (Fred)
X *
X * 3.11C - fixed a bug that was causing the entire screen to be refreshed
X * at the wrong times sometimes. Input mode was sped up as well
X * as a bug involving lines that wrapped was fixed. Changed :ta
X * a bit. Fixed bug triggered when files are > 6000 lines.
X * - GRWalter (Fred)
X *
X * 3.31A - Tony Andrews put out a divergent version of STEVIE (version 3.31).
X * I moved the important stuff over into my version.
X *
X * Here is a list of what was moved over :
X *
X *************************************************************************
X * Revision 3.29 88/06/26 14:53:19 tony
X * Added support for a simple form of the "global" command. It supports
X * commands of the form "g/pat/d" or "g/pat/p", to delete or print lines
X * that match the given pattern. A range spec may be used to limit the
X * lines to be searched.
X *
X * Revision 3.28 88/06/25 21:44:22 tony
X * Fixed a problem in the processing of colon commands that caused
X * substitutions of patterns containing white space to fail.
X *
X * Revision 3.26 88/06/10 13:44:06 tony
X * Fixed a bug involving writing out files with long pathnames. A small
X * fixed size buffer was being used. The space for the backup file name
X * is now allocated dynamically.
X *
X * Revision 1.12 88/05/03 14:39:52 tony
X * Also merged in support for DOS.
X *
X * Revision 1.11 88/05/02 21:38:21 tony
X * The code that reads files now handles boundary/error conditions much
X * better, and generates status/error messages that are compatible with
X * the real vi. Also fixed a bug in repeated reverse searches that got
X * inserted in the recent changes to search.c.
X *
X * Revision 1.10 88/05/02 07:35:41 tony
X * Fixed a bug in the routine plines() that was introduced during changes
X * made for the last version.
X *
X * Revision 1.9 88/05/01 20:10:19 tony
X * Fixed some problems with auto-indent, and added support for the "number"
X * parameter.
X *
X * Revision 1.8 88/04/30 20:00:49 tony
X * Added support for the auto-indent feature.
X *
X * Revision 1.6 88/04/28 08:19:35 tony
X * Modified Henry Spencer's regular expression library to support new
X * features that couldn't be done easily with the existing interface.
X * This code is now a direct part of the editor source code. The editor
X * now supports the "ignorecase" parameter, and multiple substitutions
X * per line, as in "1,$s/foo/bar/g".
X *
X * Revision 1.5 88/04/24 21:38:00 tony
X * Added preliminary support for the substitute command. Full range specs.
X * are supported, but only a single substitution is allowed on each line.
X *
X * Revision 1.4 88/04/23 20:41:01 tony
X * Worked around a problem with adding lines to the end of the buffer when
X * the cursor is at the bottom of the screen (in misccmds.c). Also fixed a
X * bug that caused reverse searches from the start of the file to bomb.
X *
X * Revision 1.3 88/03/24 08:57:00 tony
X * Fixed a bug in cmdline() that had to do with backspacing out of colon
X * commands or searches. Searches were okay, but colon commands backed out
X * one backspace too early.
X *
X * Revision 1.2 88/03/21 16:47:55 tony
X * Fixed a bug in renum() causing problems with large files (>6400 lines).
X *************************************************************************
X * - GRWalter (Fred)
X *
X * 3.32A - added the :[range]d command. Played with 'p' and 'P'.
X * Added undo capability to :s and :g//d commands.
X * Added '%' as a line range specifier (entire file).
X * Fixed search so that tags file from real ctags could be used.
X * Fixed undo after delete everything operation.
X * Made prt_line work in nu mode (so :g//p works right).
X * Fixed ai mode (when there was text after the cursor it didn't ai).
X * Fixed 'J' (didn't handle next line just having whitespace).
X * Fixed :[range] so it behaves like the real vi (goes to highest
X * line number in the given range).
X * Made it so that the cursor is on the last char inserted instead
X * the one right after when there is exactly 1 char right after.
X * Made change operator work properly when it ended on the
X * end of the line.
X * - GRWalter (Fred)
X *
X * 3.33A - no longer s_refresh when putting or undoing or
X * redoing until I am done. 'p', 'u' and '.' thus sped up.
X * - no longer recalculate line lengths when cursupdate() called,
X * which speeds up lots'a things (like on-screen cursoring).
X * - avoid redrawing (in s_refresh) as much as possible, which
X * speeds up (among other things) cursoring (off screen), put, undo,
X * redo, etc.
X * - GRWalter (Fred)
X *
X * 3.34A - rewrote s_refresh and updatenextline so they won't do as
X * much work. Sped up cursoring off-screen. Fixed bug in cursupdate
X * (could index through NULL pointer).
X * - GRWalter (Fred)
X *
X * 3.35A - Compiles with Lattice 5.0 now - needed miscellaneous changes.
X * - Environment variables (EXINIT) finally used.
X * - Stevie is now compiled so it's residentable.
X * - Fixed bug in insstr() (caused problems with redo of inserts).
X * - Fixed buffer overflow/corrupt messages.
X * - Tweaked s_refresh routine some more.
X * - Added __DATE__ and __TIME__ of compilation to help screen.
X * - GRWalter (Fred)
X *
X * 3.35F - Removed Nextscreen, Realscreen, updateRealscreen and
X * - redrawline. Re-wrote all screen I/O to directly update the
X * - screen when necessary, with a resulting memory and speed savings.
X * - Fixed bug in amiga.c that caused Stevie to (occasionlly) lock-up
X * upon startup until the window was resized.
X * - Removed T_SC and T_RC from term.h file (no longer used).
X * - Miscellaneous little changes.
X * - GRWalter (Fred)
X *
X * 3.35H - Fixed all routines to check memory allocation return status
X * (except for strsave() function).
X * - Fixed bug with macro outone() in amiga.c and bsd.c.
X * - GRWalter (Fred)
X *
X * 3.6 - Big jump in revision number to do last version on a Fish Disk
X * being descibed as version 3.5 (thus people will know this is
X * a later version).
X * - Miscellaneous little changes.
X * - GRWalter (Fred)
X */
X
Xchar *Version = "STEVIE - Version 3.6";
SHAR_EOF
echo "End of archive 6 (of 6)"
# if you want to concatenate archives, remove anything after this line
exit